package com.xpgk.sbwx.servlet.beingServed;

import java.io.IOException;
import java.net.URLEncoder;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xpgk.sbwx.util.AuthUtil;



public class BeingServerServlet extends HttpServlet {


	@Override
	protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException{
		String backUrl = "http://shou-8.com/shouba2.0/wxBeingServerCallback.do";
		System.out.println(URLEncoder.encode(backUrl));
		String cd = req.getRequestURI();
		System.out.println(cd);
					  //https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
		/*String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+AuthUtil.APPID
				+ "&redirect_uri="+URLEncoder.encode(backUrl)
				+ "&response_type=code"
				+ "&scope=snsapi_base"
				+ "&state=123#wechat_redirect";*/
		
		
		String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+AuthUtil.APPID
				+ "&redirect_uri="+URLEncoder.encode(backUrl)
				+ "&response_type=code"
				+ "&scope=snsapi_userinfo"
				+ "&state=123#wechat_redirect" ;
		resp.sendRedirect(url);
	}
}
